<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var score;
        var average;
        var sum = 0;
        for (var i = 1; i <= 5; i++) {
            score = prompt('请输入第' + i + '局成绩');
            //判断用户输入的是不是一个非数字
            if (isNaN(score)) {
                i--; //如果输入的是非数字让此时的弹出在重新弹出
                continue;
            }
            score -= 0; // 对score进行隐形转换
            sum += score;
            average = sum / i;
        }
        console.log('请输出获取分数的和：' + sum);
        console.log('请输出平均数：' + average);
    </script>
</body>

</html>